/*
    Copyright (C) 2011 Rémi Thebault

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef GANTTITEM_H
#define GANTTITEM_H

#include <QObject>
#include <QGraphicsItem>

#include "pcchild.h"

class GanttScene;
class GanttCycle;

class GanttItem : public QGraphicsItem, public PCChild
{
public:
	GanttItem(ProCycle* app, GanttCycle* gCycle, QGraphicsItem* parent);
	virtual ~GanttItem();

	GanttScene* gScene();

	GanttCycle* gCycle() {
		return m_gCycle;
	}

	bool hovered() const {
		return m_hovered;
	}
	void setHovered(bool hovered) {
		if (m_hovered != hovered) {
			m_hovered = hovered;
			update();
		}
	}

	virtual bool pointCanHover(const QPointF& point)=0;
	virtual bool pointCanSelect(const QPointF& point)=0;

	virtual void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
	virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
	virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
	virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
	virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

protected:
	virtual void requestSelection(bool selected=true)=0;

	GanttCycle*	m_gCycle;

	bool		m_hovered;

	bool		m_clickable;
	QPointF		m_pressPos;
};

#endif // GANTTITEM_H
